#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int arr[N][N];

int main() {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			int a;
			cin >> a;
			arr[i][j] = arr[i - 1][j] + arr[i][j - 1] - arr[i - 1][j - 1];
		}
	}
	while (q--) {
		int x1, x2, y1, y2;
		cout << arr[x2][y2] - arr[x1][y2 - 1] - arr[x2 - 1][y1] + arr[x1 - 1][y1 - 1] << endl;
	}
	return 0;
}